import permisstions from "../global.js";
// import changePage from '../changePage.js'
import Vue from "vue";
const removeDuplicateObj = (arr) => {
  let obj = {};
  arr = arr.reduce((newArr, next) => {
    obj[next.path] ? "" : (obj[next.path] = true && newArr.push(next));
    return newArr;
  }, []);
  return arr;
};
export default {
  name: "home",
  data() {
    return {
      isbackstagelr: true, //是否显示录入人员后台导航
      isbackstage: true, //是否显示后台管理导航
      ishousekeep: true, //是否显示家政管理导航
      istelRecruit: true, //是否显示后台电话招聘人员系统导航
      msgNum: "",
      items: "",
      changePwdFlag: false,
      userinfo: {
        account: "",
        department: "",
        position: "",
        grade: "",
        telnum: "",
        userid: "",
        username: "",
        identityId: "",
        type: "",
        permisstions: [],
      },
      historyData: [],
      telMark: false,
      options: [],
      value: "", //门店ID
      label: "", //门店名称
      identifyCodes:
        "1234567890ABCDEFGHIGKLMNoPQRSTUVWXYZabcdefghigklmnopqrstuvwxyz",
      bgURl: [
        {
          id: "1",
          url: "./assets/img/side1.png",
          path: "/home/dashboard",
        },
        {
          id: "2",
          url: "./assets/img/side2.png",
          path: "/home/socical",
        },
        {
          id: "3",
          url: "./assets/img/side3.png",
          path: "/home/member",
        },
        {
          id: "4",
          url: "./assets/img/side4.png",
          path: "/home/employment",
        },
        {
          id: "5",
          url: "./assets/img/side5.png",
          path: "/home/company",
        },
        {
          id: "6",
          url: "./assets/img/side6.png",
          path: "/home/banner",
        },
        {
          id: "7",
          url: "./assets/img/side7.png",
          path: "/home/newest",
        },
        {
          id: "8",
          url: "./assets/img/side8.png",
          path: "/home/feedback",
        },
        {
          id: "9",
          url: "./assets/img/side9.png",
          path: "/home/invoice",
        },
        {
          id: "10",
          url: "./assets/img/side10.png",
          path: "/home/abnormal",
        },
        {
          id: "11",
          url: "./assets/img/side11.png",
          path: "/home/",
        },
        {
          id: "12",
          url: "./assets/img/side12.png",
          path: "/home/systemManage",
        },
        {
          id: "13",
          url: "./assets/img/side13.png",
          path: "/home/contract",
        },
        {
          id: "14",
          url: "./assets/img/side14.png",
          path: "/home/flexible",
        },
        {
          id: "15",
          url: "./assets/img/side15.png",
          path: "/home/stores",
        },
      ],
      transitionName: 'slide-right'
    };
  },
  created() {
    // window.addEventListener('beforeunload', e =>this.initialize(e))
    this.initialize();
    if (this.userinfo.grade == "11") {
      this.userinfo.storesList.forEach((item) => {
        this.options.push({
          value: item.storesID,
          label: item.storesName,
        });
      });
      console.log(this.options);
      this.value = this.options[0].value;
      this.label = this.options[0].label;
      localStorage.setItem("userinfo.branchId", this.value);
    }
  },
  watch: {
    value() {
      let userMsg = JSON.parse(localStorage.getItem("userinfo"));
      userMsg.curBranchId = this.value;
      this.$store.dispatch("setCurBranchId", this.value);
      localStorage.removeItem("userinfo");
      localStorage.removeItem("entering");
      localStorage.setItem("userinfo", JSON.stringify(userMsg));
      console.log(JSON.parse(localStorage.getItem("userinfo")).curBranchId);
    },

    $route(to, from) {
      // 在这里处理路由变化
      console.log("路由变化：", to, from);
      this.userinfo.permisstions.forEach(res => {

        if (to.path == res.path) {
          res.check = true
          this.historyData.push(res)
        } else {
          res.check = false
        }
      })
      this.historyData = this.historyData.filter((item, index) => {
        return this.historyData.findIndex((other) => other.path === item.path) === index;
      });
      console.log('数组', this.historyData);
    },
    "userinfo.type"() {
      this.initialize();
      console.log(this.userinfo);
    },
  },

  mounted() { },

  methods: {
    closeTarget(data) {

      this.historyData.forEach(res => {
        if (data.path == res.path) {
          res.check = false
        }
      })
      this.historyData = this.historyData.filter((item) => data.path != item.path);

      if (this.historyData.length == 0) {
        this.historyData = []
        this.goPage({ path: '/home/dashboard' })

      } else {
        console.log(this.historyData.length - 1);
        this.goPage(this.historyData[this.historyData.length - 1])
      }

    },
    goPage(data) {
      this.$router.push(data.path)
    },
    //录入人员
    entering() {
      // this.userinfo.type = "backstages";
      console.log(this.userinfo.type);
      this.userinfo.permisstions = [];
      let entering = {
        power: "16",
        powername: "录入专员",
        tablelist: [],
        url: "./assets/img/side14.png",
        path: "/home/entering",
      };

      let pgentering = {
        power: "17",
        powername: "企业/岗位录入",
        tablelist: [],
        url: "./assets/img/side14.png",
        path: "/home/pgentering",
      };
      localStorage.removeItem("entring");
      localStorage.setItem("entring", "企业/岗位录入");
      if (this.userinfo.department == "企业/岗位录入") {
        this.userinfo.permisstions.splice(7, 0, pgentering);
      } else {
        this.userinfo.permisstions.splice(6, 0, entering);
      }
      if (this.userinfo.grade == 40) {
        this.$router.push({
          path: "./pgentering",
        });
      } else {
        this.$router.push({
          path: "./entering",
        });
      }
    },
    switchStores() {
      this.$store.dispatch("setCurBranchId", this.value);
      this.options.forEach((item) => {
        if (item.value === this.value) {
          this.label = item.label;
          this.userinfo.position = item.label;
        }
      });
    },
    changePwd() {
      this.changePwdFlag = false;
      this.$router.push({
        path: "./account",
      });
    },
    //切换到后台管理
    signInBackstage() {
      localStorage.removeItem("entring");
      console.log(this.userinfo.type);
      //  || this.userinfo.type === 'backstage'
      if (this.userinfo.grade != "10" && this.userinfo.grade != "30") {
        return false;
      }
      let str = this.userinfo.identityId.substring(
        7,
        this.userinfo.identityId.length - 7
      );
      let params = {
        account: this.userinfo.account,
        password: str,
      };
      this.$ceshiAxios2.post("/v1/platform/user/login", params).then((res) => {
        if (res.data.message === "success.") {
          let userinfo = res.data.data;
          console.log(userinfo, "列表信息。。。。。。。");
          if (
            userinfo.permisstions.length > 1 &&
            userinfo.permisstions[2].power == "3" &&
            userinfo.permisstions[2].powername == "会员管理"
          ) {
            userinfo.permisstions[2].tablelist.push({
              table: "3003",
              tablename: "消息推送",
              buttonlist: [],
            });
            userinfo.permisstions[2].tablelist.push({
              table: "3004",
              tablename: "收入管理",
              buttonlist: [],
            });

            let contract = {
              power: "13",
              powername: "电子合同",
              tablelist: [
                {
                  table: "1301",
                  tablename: "电子合同认证",
                  buttonlist: [],
                },
                {
                  table: "1302",
                  tablename: "代理人认证",
                  buttonlist: [],
                },
                {
                  table: "1303",
                  tablename: "审核人认证",
                  buttonlist: [],
                },
              ],
              url: "./assets/img/side13.png",
              path: "/home/contract",
            };
            let stores = {
              power: "15",
              powername: "发才网线下门店",
              tablelist: [
                {
                  table: "1501",
                  tablename: "门店列表",
                  buttonlist: [],
                },
                {
                  table: "1502",
                  tablename: "门店信息审核",
                  buttonlist: [],
                },
                {
                  table: "1503",
                  tablename: "返费管理",
                  buttonlist: [],
                },
                {
                  table: "1503",
                  tablename: "公告岗位管理",
                  buttonlist: [],
                },
              ],
              url: "./assets/img/side15.png",
              path: "/home/stores",
            };
            let flexible = {
              power: "14",
              powername: "灵活用工",
              tablelist: [
                {
                  table: "1401",
                  tablename: "企业需求",
                  buttonlist: [],
                },
                {
                  table: "1402",
                  tablename: "报名用户",
                  buttonlist: [],
                },
                {
                  table: "1403",
                  tablename: "个体商户认证",
                  buttonlist: [],
                },
              ],
              url: "./assets/img/side14.png",
              path: "/home/flexible",
            };

            let housemanager = {
              power: "67",
              powername: "发才网家政专区",
              tablelist: [],
              url: "./assets/img/side14.png",
              path: "/home/housemanager",
            };

            var backlog = {
              power: "43",
              url: "./assets/img/backlog.png",
              path: "/home/backlogList",
              powername: "待办事项",
            };
            let flexbleAccount = {
              power: "69",
              powername: "微信公众号后台",
              url: "./assets/img/recruit2.png",
              path: "/home/flexbleAccount",
              tablelist: [],
            };
            var log = {
              power: "44",
              url: "./assets/img/log.png",
              path: "/home/log",
              powername: "日志",
            };

            let extensionSystem = {
              power: "67",
              powername: "推广管理系统",
              tablelist: [],
              url: "./assets/img/side14.png",
              path: "/home/extensionSystem",
            };

            userinfo.permisstions.splice(8, 0, extensionSystem);
            userinfo.permisstions.splice(2, 0, contract);
            userinfo.permisstions.splice(4, 0, stores);
            userinfo.permisstions.splice(5, 0, flexible);
            userinfo.permisstions.splice(6, 0, housemanager);
            userinfo.permisstions.splice(3, 0, flexbleAccount);

            userinfo.permisstions.push(backlog, log);
          }
          let prev = "",
            next = "";
          for (let i = 0; i < 7; i++) {
            prev +=
              this.identifyCodes[this.randomNum(0, this.identifyCodes.length)];
            next +=
              this.identifyCodes[this.randomNum(0, this.identifyCodes.length)];
          }
          userinfo.type = "backstage";
          userinfo.identityId = prev + str + next;

          if (userinfo.grade == "30") {
            userinfo.permisstions = [
              {
                path: "/home/member",
                power: "3",
                powername: "会员管理",
                tablelist: [
                  {
                    buttonlist: [
                      {
                        button: "300104",
                        buttonname: "会员导出",
                      },
                    ],
                    table: "3001",
                    tablename: "会员列表",
                  },
                ],
                url: "./assets/img/side3.png",
              },
            ];
          }

          this.checkHuman = userinfo.username;
          for (const key in userinfo.permisstions) {
            // 获取到 userinfo.permisstions 的0-10的这个  键
            for (const key1 in this.bgURl) {
              // 把 this.bgURl [key1] 的id  是不是  ====  userinfo.permisstions  [key] 里面的power
              if (userinfo.permisstions[key].power === this.bgURl[key1].id) {
                // 是的话  就把 其他的也都给   userinfo.permisstions
                userinfo.permisstions[key].url = this.bgURl[key1].url;
                userinfo.permisstions[key].path = this.bgURl[key1].path;
              }
            }
          }
          console.log(userinfo);
          localStorage.removeItem("userinfo");
          localStorage.setItem("userid", res.data.data.userid);
          this.userinfo = userinfo;
          localStorage.setItem("userinfo", JSON.stringify(userinfo));
          localStorage.setItem("checkHuman", this.checkHuman);

          if (localStorage.getItem("currentUserinfo") == null) {
            localStorage.setItem("currentUserinfo", JSON.stringify(userinfo));
          }

          this.$router.push({
            path: userinfo.permisstions[0].path,
          });
        }
      });
    },
    handleOpen(res, data) {
      console.log(res);
      console.log(data);
      if (data.path == "/home/overviewPage") {
        this.$store.commit("telValue", true);
      }
      if (res == 999) {
        window.location.href = "http://baidu.com";
      }
    },
    //切换到家政板块
    signInHousekeep() {
      let telnum = localStorage.getItem("telnum");
      console.log(telnum);
      // if(telnum!==15202120781||telnum!==13917522570){
      // 	return;
      // }
      if (this.userinfo.grade != "10" || this.userinfo.type === "housekeep") {
        return false;
      }
      let str = this.userinfo.identityId.substring(
        7,
        this.userinfo.identityId.length - 7
      );
      console.log(str);
      let params = {
        account: this.userinfo.account,
        password: str,
      };
      console.log(params);
      let houseList = [
        {
          power: "21",
          powername: "概览",
          url: "./assets/img/house1.png",
          path: "/home/houseIndex",
        },
        {
          power: "22",
          powername: "线上门店管理",
          url: "./assets/img/house2.png",
          path: "/home/StoreManagement",
        },
        {
          power: "23",
          powername: "雇主管理",
          url: "./assets/img/house3.png",
          path: "/home/employer",
        },
        {
          power: "24",
          powername: "家政从业者管理",
          url: "./assets/img/house4.png",
          path: "/home/practitioner",
        },
        {
          power: "25",
          powername: "岗位招聘管理",
          url: "./assets/img/side14.png",
          path: "/home/postrecruitmen",
        },
        {
          power: "26",
          powername: "点评管理",
          url: "./assets/img/house5.png",
          path: "/home/comment",
        },
        {
          power: "27",
          powername: "月子会所管理",
          url: "./assets/img/house6.png",
          path: "/home/Confinement",
        },
        // {power: "999", powername: "可视化数据", url: "./assets/img/house6.png"},
        /* {power: "26", powername: "月子会所管理", url: "./assets/img/house6.png", path: "/home/clubManage"},
        {power: "27", powername: "家政网点管理", url: "./assets/img/house7.png", path: "/home/networkManage"}, */
      ];
      this.userinfo.permisstions = houseList;
      this.$router.push({
        path: houseList[0].path,
      });
      // this.$axios
      // .$post('https://zjsy.fcw-china.com/housekeeping/Login/selectLogin',params)
      // .then(res => {
      // 	console.log(res);
      // 	if (res.data.code === 1000){
      // 		let userinfo = res.data.data;
      // 		this.checkHuman = userinfo.username;
      // 		let prev = '',next = '';
      // 		for (let i = 0; i < 7; i++) {
      // 		  prev += this.identifyCodes[this.randomNum(0, this.identifyCodes.length)];
      // 		  next += this.identifyCodes[this.randomNum(0, this.identifyCodes.length)];
      // 		}
      // 		userinfo.type = 'housekeep';
      // 		userinfo.identityId = prev + str + next;
      // 		console.log(userinfo);
      // 		userinfo.position = '总账户';
      // 		userinfo.department = 'CEO';
      // 		let	houseList = [
      // 			{power: "21", powername: "概览", url: "./assets/img/house1.png", path: "/home/houseIndex"},
      // 			{power: "22", powername: "雇主管理", url: "./assets/img/house2.png", path: "/home/employer"},
      // 			{power: "23", powername: "家政从业者管理", url: "./assets/img/house3.png", path: "/home/practitioner"},
      // 			{power: "24", powername: "岗位招聘管理", url: "./assets/img/house4.png", path: "/home/enterprise"},
      // 			{power: "25", powername: "线下辅导站管理", url: "./assets/img/house5.png", path: "/home/warrant"},
      // 			/* {power: "26", powername: "月子会所管理", url: "./assets/img/house6.png", path: "/home/clubManage"},
      // 			{power: "27", powername: "家政网点管理", url: "./assets/img/house7.png", path: "/home/networkManage"}, */
      // 		];
      // 		userinfo.permisstions = houseList;
      // 		localStorage.removeItem('userinfo');
      // 		localStorage.setItem(
      // 		  'userid',
      // 		  res.data.data.userid
      // 		)
      // 		this.userinfo = userinfo;
      // 		localStorage.setItem('userinfo', JSON.stringify(userinfo))
      // 		localStorage.setItem(
      // 		  'checkHuman',
      // 		  this.checkHuman
      // 		)
      // 		if (localStorage.getItem('currentUserinfo') == null) {
      // 		  localStorage.setItem(
      // 		    'currentUserinfo',
      // 		    JSON.stringify(userinfo)
      // 		  )
      // 		}
      // 		this.$router.push({
      // 		  path: userinfo.permisstions[0].path
      // 		})
      // 	}
      // })
    },
    //切换到电话招聘板块
    signInTelRecruit() {
      console.log(this.userinfo.type);
      if (
        this.userinfo.grade != "10" &&
        this.userinfo.grade != "30"
        //  ||
        // this.userinfo.type === "telRecruit"
      ) {
        return false;
      }
      let str = this.userinfo.identityId.substring(
        7,
        this.userinfo.identityId.length - 7
      );
      let params = {
        accountNumber: this.userinfo.account,
        passWord: str,
      };
      this.$telAxios
        .post("/v1/librarian/selectFlexibileUserInfo", params)
        .then((res) => {
          console.log(res);
          if (res.data.code === 1000) {
            let userinfo = res.data.data;
            this.checkHuman = userinfo.name;
            userinfo.username = userinfo.name;
            let prev = "",
              next = "";
            for (let i = 0; i < 7; i++) {
              prev +=
                this.identifyCodes[
                this.randomNum(0, this.identifyCodes.length)
                ];
              next +=
                this.identifyCodes[
                this.randomNum(0, this.identifyCodes.length)
                ];
            }
            userinfo.type = "telRecruit";
            userinfo.account = userinfo.accountNumber;
            delete userinfo.accountNumber;
            userinfo.identityId = prev + str + next;
            if (userinfo.grade === "10") {
              userinfo.position = "总账户";
              userinfo.department = "CEO";
            }
            let recruitList = [
              {
                power: "61",
                powername: "概览",
                url: "./assets/img/recruit2.png",
                path: "/home/overviewPage",
              },
              {
                power: "41",
                powername: "电话招聘人员管理",
                url: "./assets/img/recruit1.png",
                path: "/home/personnelManage",
              },
              {
                power: "42",
                powername: "项目管理",
                url: "./assets/img/recruit2.png",
                path: "/home/projectManage",
              },
              {
                power: "88",
                powername: "人才库",
                url: "./assets/img/recruit2.png",
                path: "/home/talentpPool",
              },
              {
                power: "98",
                powername: "发才网人才库",
                url: "./assets/img/recruit2.png",
                path: "/home/fcwTelentPool",
              },
            ];
            localStorage.setItem("pageTitle", "电话招聘人员管理");
            this.$store.dispatch("setPageTitle", "电话招聘人员管理");

            userinfo.permisstions = recruitList;
            localStorage.removeItem("userinfo");
            localStorage.setItem("userid", userinfo.userId);
            this.userinfo = userinfo;
            localStorage.setItem("userinfo", JSON.stringify(userinfo));
            localStorage.setItem("checkHuman", this.checkHuman);
            if (localStorage.getItem("currentUserinfo") == null) {
              localStorage.setItem("currentUserinfo", JSON.stringify(userinfo));
            }
            this.$router.push({
              path: userinfo.permisstions[0].path,
            });
          } else {
            this.$message({
              message: res.data.message,
              type: "warning",
            });
          }
        });
    },
    // 生成随机数
    randomNum(min, max) {
      return Math.floor(Math.random() * (max - min) + min);
    },
    initialize() {
      console.log(localStorage.getItem("entring"));
      // 先从 localStorage里面获取到了userinfo，然后把他转换成js形式设置到userinfo里面
      this.userinfo = JSON.parse(localStorage.getItem("userinfo"));
      console.log(this.userinfo);
      // console.log(this.userinfo.permisstions)
      // 然后再把userinfo里面的permisstions设置成permisstions
      // 然后再把localStorage里面的permisstions转化成json格式放到this.userinfo.permisstions
      localStorage.setItem(
        "permisstions",
        JSON.stringify(this.userinfo.permisstions)
      );
      this.userinfo.permisstions = JSON.parse(
        localStorage.getItem("permisstions")
      );
      this.$store.dispatch("setPageTitle", localStorage.getItem("pageTitle"));
      if (this.userinfo.type === "backstage") {
        this.isbackstage = true;
        this.ishousekeep = false;
        this.istelRecruit = false;
        var backlog = {
          id: "13",
          url: "./assets/img/backlog.png",
          path: "/home/backlogList",
          powername: "待办事项",
        };
        var log = {
          id: "14",
          url: "./assets/img/log.png",
          path: "/home/log",
          powername: "日志",
        };
        var entering = {
          id: "15",
          url: "./assets/img/side14.png",
          path: "/main/entering/index.vue",
          powername: "企业/岗位录入",
        };

        // 把backlog和log   push到  this.userinfo.permisstions  这里面来  这样的话就能不管左边写了几列都能在最后加上这两列
        this.userinfo.permisstions.push(backlog, log);
        if (this.userinfo.grade == 40) {
          this.entering();
        }
        if (this.userinfo.account == "fcwlhyg") {
          var PlatformQualification = {
            id: "71",
            url: "./assets/img/side14.png",
            path: "/home/flexibleEmployment/PlatformQualification",
            powername: "平台资质",
          };
          var companySearch = {
            id: "72",
            url: "./assets/img/side14.png",
            path: "/home/flexibleEmployment/companySearch",
            powername: "企业查询",
          };
          var peopleSearch = {
            id: "73",
            url: "./assets/img/side14.png",
            path: "/home/flexibleEmployment/peopleSearch",
            powername: "自然人查询",
          };
          var jobSearch = {
            id: "74",
            url: "./assets/img/side14.png",
            path: "/home/flexibleEmployment/jobSearch",
            powername: "任务查询",
          };
          var contactSearch = {
            id: "75",
            url: "./assets/img/side14.png",
            path: "/home/flexibleEmployment/contactSearch",
            powername: "合同查询",
          };
          var computerSearch = {
            id: "76",
            url: "./assets/img/side14.png",
            path: "/home/flexibleEmployment/computerSearch",
            powername: "结算查询",
          };
          var billSearch = {
            id: "77",
            url: "./assets/img/side14.png",
            path: "/home/flexibleEmployment/billSearch",
            powername: "发票查询",
          };

          this.userinfo.permisstions.splice(
            0,
            this.userinfo.permisstions.length
          );
          this.userinfo.permisstions.push(PlatformQualification);
          this.userinfo.permisstions.push(companySearch);
          this.userinfo.permisstions.push(peopleSearch);
          this.userinfo.permisstions.push(jobSearch);
          this.userinfo.permisstions.push(computerSearch);
          this.userinfo.permisstions.push(contactSearch);
          this.userinfo.permisstions.push(billSearch);
          this.userinfo.permisstions.forEach((res) => { });
        } else if (this.userinfo.account == "kfgl001") {
          this.userinfo.permisstions = [];
          // recruitList
          let recruitList = [
            {
              power: "61",
              powername: "概览",
              url: "./assets/img/recruit2.png",
              path: "/home/overviewPage",
            },
            {
              power: "41",
              powername: "电话招聘人员管理",
              url: "./assets/img/recruit1.png",
              path: "/home/personnelManage",
            },
            {
              power: "42",
              powername: "项目管理",
              url: "./assets/img/recruit2.png",
              path: "/home/projectManage",
            },
            {
              power: "88",
              powername: "人才库",
              url: "./assets/img/recruit2.png",
              path: "/home/talentpPool",
            },
            {
              power: "98",
              powername: "发才网人才库",
              url: "./assets/img/recruit2.png",
              path: "/home/fcwTelentPool",
            },
          ];
          this.userinfo.permisstions.splice(
            0,
            this.userinfo.permisstions.length
          );
          this.userinfo.permisstions = recruitList;
        }

        if (this.userinfo.account == "wechatManager") {
          var PlatformQualification = {
            id: "71",
            url: "",
            path: "/home/wechatManager/PlatformQualification",
            powername: "平台资质",
          };
          var companySearch = {
            id: "72",
            url: "./assets/img/side14.png",
            path: "/home/wechatManager/Overview",
            powername: "概览",
          };
          var peopleSearch = {
            id: "73",
            url: "./assets/img/side14.png",
            path: "/home/wechatManager/financeManager",
            powername: "财务管理",
          };
          var jobSearch = {
            id: "74",
            url: "./assets/img/side14.png",
            path: "/home/wechatManager/companyManager",
            powername: "企业管理",
          };
          var contactSearch = {
            id: "75",
            url: "./assets/img/side14.png",
            path: "/home/wechatManager/severManager",
            powername: "服务者管理",
          };
          var computerSearch = {
            id: "76",
            url: "./assets/img/side14.png",
            path: "/home/wechatManager/projectManager",
            powername: "项目管理",
          };
          var billSearch = {
            id: "77",
            url: "./assets/img/side14.png",
            path: "/home/wechatManager/projectProcess",
            powername: "项目进度",
          };
          var orderSearch = {
            id: "78",
            url: "./assets/img/side14.png",
            path: "/home/wechatManager/orderManager",
            powername: "订单管理",
          };

          var recharge = {
            id: "100",
            url: "./assets/img/side14.png",
            path: "/home/wechatManager/recharge",
            powername: "报酬直发",
          };

          this.userinfo.permisstions.splice(
            0,
            this.userinfo.permisstions.length
          );
          this.userinfo.permisstions.push(PlatformQualification);
          this.userinfo.permisstions.push(companySearch);
          this.userinfo.permisstions.push(peopleSearch);
          this.userinfo.permisstions.push(jobSearch);
          this.userinfo.permisstions.push(computerSearch);
          this.userinfo.permisstions.push(contactSearch);
          this.userinfo.permisstions.push(billSearch);
          this.userinfo.permisstions.push(orderSearch);
          this.userinfo.permisstions.push(recharge);
          this.userinfo.permisstions.forEach((res) => { });
        }
        if (this.userinfo.account == "kefumanager") {
          let recruitList = [{
            power: "61",
            powername: "概览",
            url: "./assets/img/recruit2.png",
            path: "/home/overviewPage",
          },
          {
            power: "41",
            powername: "电话招聘人员管理",
            url: "./assets/img/recruit1.png",
            path: "/home/personnelManage",
          },
          {
            power: "42",
            powername: "项目管理",
            url: "./assets/img/recruit2.png",
            path: "/home/projectManage",
          },
          {
            power: "88",
            powername: "人才库",
            url: "./assets/img/recruit2.png",
            path: "/home/talentpPool",
          },
          {
            power: "98",
            powername: "发才网人才库",
            url: "./assets/img/recruit2.png",
            path: "/home/fcwTelentPool",
          },
          ];
          localStorage.setItem("pageTitle", "电话招聘人员管理");
          this.$store.dispatch("setPageTitle", "电话招聘人员管理");
          this.userinfo.type = "telRecruit"
          this.userinfo.permisstions = recruitList;
          localStorage.removeItem("userinfo");
          localStorage.setItem("userid", this.userinfo.userId);
          localStorage.setItem("userinfo", JSON.stringify(this.userinfo));
          localStorage.setItem("checkHuman", this.checkHuman);
          
          this.$router.push({
            path: this.userinfo.permisstions[0].path, 
          });  
          
        }
        console.log(this.userinfo.permisstions);
        // if (this.userinfo.permisstions.length > 16) {
        // 	this.userinfo.permisstions.splice(16, 2);
        // 	// this.userinfo.permisstions.splice(17, 1);
        // }

        this.userinfo.permisstions = removeDuplicateObj(
          this.userinfo.permisstions
        );

        if (this.userinfo.grade === "30") {
          this.userinfo.permisstions = [
            {
              path: "/home/member",
              power: "3",
              powername: "会员管理",
              tablelist: [
                {
                  buttonlist: [
                    {
                      button: "300104",
                      buttonname: "会员导出",
                    },
                  ],
                  table: "3001",
                  tablename: "会员列表",
                },
              ],
              url: "./assets/img/side3.png",
            },
          ];
        }
        Vue.prototype.GLOBAL = permisstions(); //挂载到Vue实例上面

        if (localStorage.getItem("entring") == "企业/岗位录入") {
          var entering = {
            power: "16",
            powername: "录入专员",
            tablelist: [],
            url: "./assets/img/side14.png",
            path: "/home/entering",
          };
          this.userinfo.permisstions = [];
          this.userinfo.permisstions.push(entering);
          console.log("录入");
        } else {
        }
      } else if (this.userinfo.grade == 40) {
        this.isbackstagelr = true;
        this.isbackstage = false;
        this.signInTelRecruit = false;
        this.entering();
      } else if (this.userinfo.type === "housekeep") {
        this.ishousekeep = true;
        this.isbackstage = false;
        this.istelRecruit = false;
      } else {
        this.ishousekeep = false;
        this.isbackstage = false;
        this.istelRecruit = true;
      }
      if (this.userinfo.grade === "10") {
        this.ishousekeep = true;
        this.isbackstage = true;
        this.istelRecruit = true;
      } else if (this.userinfo.grade === "30") {
        this.ishousekeep = false;
        this.isbackstage = true;
        this.istelRecruit = true;
      }

      if (this.userinfo.account == "FC666666") {
        this.isbackstage = true;
        this.isbackstagelr = true;
      } else if (this.userinfo.grade == 40) {
        this.isbackstage = false;
        this.isbackstagelr = true;
        this.istelRecruit = false;
      } else if (
        this.userinfo.grade == "10" &&
        this.userinfo.account == "fc666666"
      ) {
        this.isbackstage = true;
        this.isbackstagelr = true;
      } else if (
        this.userinfo.type == "telRecruit" &&
        this.userinfo.grade == "10" &&
        this.userinfo.account == "DHZP666"
      ) {
        this.ishousekeep = false;
        this.isbackstagelr = false;
        this.istelRecruit = true;
        this.isbackstage = false;
      } else if (this.userinfo.type === "telRecruit") {
        this.ishousekeep = false;
        this.isbackstagelr = false;
        this.istelRecruit = true;
      } else {
        this.isbackstage = true;
        this.isbackstagelr = false;
      }
    },
    logoutBtn() {
      this.$confirm("是否确定退出登录?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(
        () => {
          let that = this;
          localStorage.removeItem("entring");
          localStorage.removeItem("userinfo");
          localStorage.removeItem("userid");
          localStorage.removeItem("permisstions");
          localStorage.removeItem("checkHuman");
          that.$router.push({
            path: "/login",
          });
        },
        () => {
          console.log("取消成功！");
        }
      );
    },
  },
};
